const pkg = require('./package')
import { resolve } from 'path'


module.exports = {
  mode: 'universal',

  // nuxt官方推荐环境变量和base_url配置方法
  // 通过process.env.BASE_URL获得base_url
  // 见：https://www.cnblogs.com/djjlovedjj/p/10268253.html
  env: {
    BASE_URL: process.env.BASE_URL,
    NODE_ENV: process.env.NODE_ENV
  },

  /*
  ** Headers of the page
  */
  head: {
    // title: pkg.name,
    title: "侯府点餐",
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: pkg.description }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ],
    script: [
      // {
      //   src: 'https://unpkg.com/cube-ui/lib/cube.min.js'
      // }     
    ]
  },

  /*
  ** Customize the progress-bar color
  */
  loading: { color: '#fff' },

  /*
  ** Global CSS
  */
  css: [
    {
      src: 'cube-ui/lib/cube.min.css'
    },
    {
      src: './static/font/iconfont.css'
    }
  ],

  /*
  ** Plugins to load before mounting the App
  */
  plugins: [
    {src:'@/plugins/cube-ui', ssr:true},
    {src:'@/plugins/register', ssr:false}
  ],

  /*
  ** Nuxt.js modules
  */
  modules: [
    // 请求代理配置，解决跨域
    // 安装依赖项
    // npm install @gauseen/nuxt-proxy --save
    '@gauseen/nuxt-proxy',
  ],

  /*
  ** Build configuration
  */
  build: {
    /*
    ** You can extend webpack config here
    */
    extend(config, ctx) {
      if (ctx.isClient) {
        config.resolve.alias['cube-ui'] = 'cube-ui/lib'
        config.resolve.alias['cubeuisrc'] = resolve(__dirname,'node_modules/cube-ui/src')
        config.resolve.alias['components'] = resolve(__dirname, '/components')

        // console.log('打印cubevariable')
        // console.log(config.resolve.alias['cubevariable'])
        // config.plugins = [
        //     new TransformModulesPlugin()
        //   ]
      }
      // var TransformModulesPlugin = require('webpack-transform-modules-plugin')
      // config.plugins.push(TransformModulesPlugin())
      // console.log(config.plugins)

    }
  }
}
